import http from './interface'


// 获取短信
export const sendCode = (data) => {
	return http.request({
		url: '/user/sendCode',
		method: 'GET',
		data,
		// handle:true
	})
}

// 登录
export const login = (data) => {
	return http.request({
		url: '/user/login',
		method: 'GET',
		data,
		// handle:true
	})
}

// 注册
export const register = (data) => {
	return http.request({
		url: '/user/register',
		method: 'GET',
		data,
		// handle:true
	})
}

// 获取时间戳
export const getTime = (data) => {
	return http.request({
		url: '/user/datamd',
		method: 'GET',
		data,
		// handle:true
	})
}

// 修改密码
export const resetPwd = (data) => {
	return http.request({
		url: '/user/updatePassword',
		method: 'GET',
		data,
		// handle:true
	})
}

// 修改用户名
export const resetName = (data) => {
	return http.request({
		url: '/user/updatename',
		method: 'GET',
		data,
		// handle:true
	})
}

// 获取注册助记词
export const getRegisterMnemonic = (data) => {
	return http.request({
		url: '/word/getWord',
		method: 'GET',
		data,
		// handle:true
	})
}
// 获取登录助记词
export const getLoginMnemonic = (data) => {
	return http.request({
		url: '/word/loginWord',
		method: 'GET',
		data,
		// handle:true
	})
}

// 获取打乱的助记词
export const getMnemonicHS = (data) => {
	return http.request({
		url: '/word/upsetWord',
		method: 'GET',
		data,
		// handle:true
	})
}

// 验证登录助记词
export const verifyMnemonic = (data) => {
	return http.request({
		url: '/word/vWord',
		method: 'GET',
		data,
		// handle:true
	})
}

// 验证注册助记词
export const verifyRegisterMnemonic = (data) => {
	return http.request({
		url: '/word/vWordYes',
		method: 'GET',
		data,
		// handle:true
	})
}


// 获取用户等级
export const getUserlv = (data) => {
	return http.request({
		url: '/getWc/userlv',
		method: 'GET',
		data,
		// handle:true
	})
}
/*
 * 钱包部分
 */
// 钱包余额
export const getWallet = (data) => {
	return http.request({
		url: '/getWc/release',
		method: 'GET',
		data,
		// handle:true
	})
}

// 验证交易密码
export const buyLABpwd = (data) => {
	return http.request({
		url: '/getWc/trading',
		method: 'GET',
		data,
		// handle:true
	})
}
// 获取LABres投入总数
export const investLABredSum = (data) => {
	return http.request({
		url: '/getWc/getIce',
		method: 'GET',
		data,
		// handle:true
	})
}
// 投入LABret
export const buyWealth = (data) => {
	return http.request({
		url: '/wealth/buyWealth',
		method: 'GET',
		data,
		// handle:true
	})
}
// 兑换LABred
export const exchangeLABred = (data) => {
	return http.request({
		url: '/getWc/exchange',
		method: 'GET',
		data,
		// handle:true
	})
}
// 兑换LABtk
export const exchangeLABtk = (data) => {
	return http.request({
		url: '/getWc/seedOrtk',
		method: 'GET',
		data,
		// handle:true
	})
}
// 获取LABblue数量
export const getLABblueSum = (data) => {
	return http.request({
		url: '/getWc/getIce',
		method: 'GET',
		data,
		// handle:true
	})
}
// LABtk转账
export const transferLABtk = (data) => {
	return http.request({
		url: '/service/turnOut',
		method: 'GET',
		data,
		// handle:true
	})
}

/*
 * 个人中心部分
 */
// 直系下级
export const getAllConnections = (data) => {
	return http.request({
		url: '/service/getAllConnections',
		method: 'GET',
		data,
		// handle:true
	})
}
// 商家申请
export const applyStore = (data) => {
	return http.request({
		url: '/getWc/goods',
		method: 'POST',
		data,
		// handle:true
	})
}
// 商家申请状态
export const applyStoreStatus = (data) => {
	return http.request({
		url: '/getWc/findGood',
		method: 'GET',
		data,
		// handle:true
	})
}

// 邀请直系下级获得奖励
export const getInviteReward = (data) => {
	return http.request({
		url: '/getWc/invite',
		method: 'GET',
		data,
		// handle:true
	})
}

// 版本检查
export const getVersion = (data) => {
	return http.request({
		url: '/word/getVersion',
		method: 'GET',
		data,
		// handle:true
	})
}

/*
 * LAB流水
 */
export const getLABredBill = (data) => {
	return http.request({
		url: '/getWc/red',
		method: 'GET',
		data,
		// handle:true
	})
}
export const getLABbuleBill = (data) => {
	return http.request({
		url: '/getWc/sf',
		method: 'GET',
		data,
		// handle:true
	})
}
export const getSEEDBill = (data) => {
	return http.request({
		url: '/getWc/seed',
		method: 'GET',
		data,
		// handle:true
	})
}
export const getLABtkBill = (data) => {
	return http.request({
		url: '/getWc/tk',
		method: 'GET',
		data,
		// handle:true
	})
}
// 获取投入LABred
export const getLABredInvest = (data) => {
	return http.request({
		url: '/Books/LabRed',
		method: 'GET',
		data,
		// handle:true
	})
}
// 获取LABbule产出
export const getLABbuleOutput = (data) => {
	return http.request({
		url: '/Books/bonus',
		method: 'GET',
		data,
		// handle:true
	})
}


/*
 * 上传图片
 * 
 */
export const upload_one = (data) => {
	return new Promise((resolve, reject) => {
	    uni.showLoading({
	        title:'上传中'
	    })
	    uni.uploadFile({
	        url: http.config.baseUrl + data.url,
	        filePath: data.path,
	        name: 'file',
			formData: {
				uid: data.uid,
			},
	        success: (uploadFileRes) => {
	            if("string"===typeof uploadFileRes.data){
	                resolve(JSON.parse(uploadFileRes.data))
	            }else{
	                resolve(uploadFileRes.data)
	            } 
	        },
	        complete() {
	            uni.hideLoading()
	        }
	    });
	})
}

export const upload = (data) => {
	let num = data.path_arr.length;
	return new Promise(async (resolve, reject) => {
		let img_urls = []
		for (let i = 0; i < num; i++) {
			data.path = data.path_arr[i]
			let img_url = await upload_one(data);
			console.log(img_url)
			img_urls.push(img_url)
		};
		console.log("全部上传成功")
		resolve(img_urls)
	})
}

// 默认全部导出  import api from '@/common/vmeitime-http/'
export default {
	sendCode,
	login, // 登录、注册
	register,
	resetPwd,
	resetName,
	getRegisterMnemonic,
	getLoginMnemonic,
	getMnemonicHS,
	verifyMnemonic,
	verifyRegisterMnemonic,
	getTime,
	exchangeLABred,
	exchangeLABtk,
	buyLABpwd,
	buyWealth,
	getUserlv,
	getLABblueSum,
	getWallet,
	investLABredSum,
	getAllConnections, // 个人中心
	getInviteReward,
	getVersion,
	applyStore,
	applyStoreStatus,
	getLABredBill, // 流水
	getLABbuleBill,
	getSEEDBill,
	getLABtkBill,
	getLABredInvest,
	getLABbuleOutput,
	transferLABtk,
	upload_one, // 图片上传
	upload
}
